package com.woan.api.idao.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.transform.Transformers;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.woan.api.idao.SysRoleIDAO;
import com.woan.api.model.SysRole;
import com.woan.api.model.ZbConfig;

/**
 * A data access object (DAO) providing persistence and search support for
 * SysRole entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.woan.api.model.SysRole
 * @author MyEclipse Persistence Tools
 */

public class SysRoleDAO extends HibernateDaoSupport  implements SysRoleIDAO  {
	public boolean save(SysRole sysRole)
	{
		try {
			getHibernateTemplate().save(sysRole);
			return true;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public SysRole findById(java.lang.String id) {
		try {
			SysRole instance = (SysRole) getHibernateTemplate().get(
					"com.woan.api.model.SysRole", id);
			return instance;
		} catch (RuntimeException re) {
		
			throw re;
		}
	}
	public SysRole findByRoleName(java.lang.String rolename) {
		try {
			String hql = "from SysRole where roleName = '" + rolename + "'";
			List<SysRole>  list=this.getHibernateTemplate().find(hql.toString());
			if(list!=null&&list.size()>0)
				return list.get(0);
			else
				return null;
		} catch (RuntimeException re) {
		
			throw re;
		}
	}	
}